home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 August / DPPCPRO0805.ISO / Assets / Interface / Main.dxr / Flash Components_1_Centre pane.swf / scripts / __Packages / HighlightBoxout.as < prev    next >
Encoding:
Text File  |  2005-05-20  |  7.8 KB  |  249 lines

  1. class HighlightBoxout extends MovieClip
  2. {
  3.    var __progress;
  4.    var background;
  5.    var __target;
  6.    var __title;
  7.    var __titleText;
  8.    var __desc;
  9.    var __bgWidth;
  10.    var __bgHeight;
  11.    var onRollOver;
  12.    var boxoutBorder;
  13.    var onRollOut;
  14.    var onPress;
  15.    var dispatchEvent;
  16.    static var symbolName = "HighlightBoxout";
  17.    static var symbolOwner = HighlightBoxout;
  18.    var className = "HighlightBoxout";
  19.    static var version = "0.0.0.1";
  20.    function HighlightBoxout()
  21.    {
  22.       super();
  23.       mx.events.EventDispatcher.initialize(this);
  24.    }
  25.    function init(Void)
  26.    {
  27.       this.__progress = new mx.controls.ProgressBar();
  28.       this.__progress.label = "Highlight information will appear here";
  29.       this.__progress.labelPlacement = "bottom";
  30.       this.__progress.mode = "manual";
  31.       super.init();
  32.    }
  33.    function size(Void)
  34.    {
  35.       super.size();
  36.    }
  37.    function get height()
  38.    {
  39.       return this.background._height;
  40.    }
  41.    function set target(tgt)
  42.    {
  43.       this.__target = tgt;
  44.    }
  45.    function set title(titleText)
  46.    {
  47.       trace("HighlightBoxout received title: " + titleText);
  48.       this.__title = this.attachMovie("TextArea","title",3);
  49.       this.__title.hScrollPolicy = this.__title.vScrollPolicy = "off";
  50.       this.__title.label.selectable = this.__title.editable = this.__title.wordWrap = false;
  51.       this.__title._x = 10;
  52.       this.__title._y = 5;
  53.       this.__title.setSize(340,32);
  54.       this.__title.html = true;
  55.       this.__title.setStyle("styleName","boxTitleStyle");
  56.       this.__title.styleSheet = _global.textStyles;
  57.       this.__title.embedFonts = true;
  58.       this.__titleText = this.removeHTMLTags(titleText);
  59.       this.__title.text = "<boxtitle>" + this.__titleText + "</boxtitle>";
  60.       trace("TITLE HEIGHT: " + this.__title._height);
  61.    }
  62.    function set desc(descText)
  63.    {
  64.       this.__desc = this.attachMovie("TextArea","desc",5);
  65.       this.__desc._x = 10;
  66.       this.__desc._y = 36;
  67.       this.__desc.setSize(340,85);
  68.       this.__desc.html = true;
  69.       this.__desc.hScrollPolicy = this.__desc.vScrollPolicy = "off";
  70.       this.__desc.label.selectable = this.__desc.editable = false;
  71.       this.__desc.wordWrap = true;
  72.       this.__desc.embedFonts = true;
  73.       this.__desc.setStyle("styleName","boxDescStyle");
  74.       this.__desc.styleSheet = _global.textStyles;
  75.       this.__desc.text = "<boxdesc>" + descText + "</boxdesc>";
  76.    }
  77.    function set styleSheet(css)
  78.    {
  79.       this.__title.styleSheet = this.__desc.styleSheet = css;
  80.    }
  81.    function set enabled(activeStatus)
  82.    {
  83.       if(activeStatus == true)
  84.       {
  85.          var _loc2_ = new TextFormat();
  86.          _loc2_.color = 0;
  87.          var _loc4_ = "<headline>" + this.__title.htmlText.slice(18,this.__title.htmlText.length - 19) + "</headline>";
  88.          this.__title.setTextFormat(_loc2_);
  89.          this.__title.setNewTextFormat(_loc2_);
  90.          this.__title.htmlText = _loc4_;
  91.          this.drawBackground(true,this.__bgWidth,this.__bgHeight);
  92.          this.onRollOver = function()
  93.          {
  94.             this.__title.text = "<boxtitle><a class=\'underlined\'>" + this.__titleText + "</a></boxtitle>";
  95.             var _loc2_ = new Color(this.boxoutBorder);
  96.             _loc2_.setRGB("0x990000");
  97.          };
  98.          this.onRollOut = function()
  99.          {
  100.             this.__title.text = "<boxtitle>" + this.__titleText + "</boxtitle>";
  101.             var _loc2_ = new Color(this.boxoutBorder);
  102.             _loc2_.setRGB("0xCCC7B8");
  103.          };
  104.          this.onPress = function()
  105.          {
  106.             this.__title.text = "<boxtitle>" + this.__titleText + "</boxtitle>";
  107.             var _loc2_ = new Color(this.boxoutBorder);
  108.             _loc2_.setRGB("0xCCC7B8");
  109.             this.sendMessage("Highlight pressed");
  110.          };
  111.       }
  112.       else
  113.       {
  114.          _loc2_ = new TextFormat();
  115.          _loc2_.color = 8421504;
  116.          _loc4_ = "<headlinedisabled>" + this.__title.htmlText.slice(10,this.__title.htmlText.length - 11) + "</headlinedisabled>";
  117.          this.__title.setTextFormat(_loc2_);
  118.          this.__title.setNewTextFormat(_loc2_);
  119.          this.__title.htmlText = _loc4_;
  120.          this.drawBackground(false,this.__bgWidth,this.__bgHeight);
  121.          this.onRollOver = this.onRollOut = this.onPress = null;
  122.       }
  123.       this.__desc.label.selectable = false;
  124.       this.__title.enabled = this.__desc.enabled = activeStatus;
  125.    }
  126.    function drawBackground(enable, w, h)
  127.    {
  128.       trace("in drawBackground");
  129.       trace(this);
  130.       if(enable)
  131.       {
  132.          trace("enabled");
  133.          var lightCol = 15591381;
  134.          var darkCol = 13420472;
  135.       }
  136.       else
  137.       {
  138.          trace("disabled");
  139.          var lightCol = 15658734;
  140.          var darkCol = 14540253;
  141.       }
  142.       var borderWidth = 1;
  143.       this.createEmptyMovieClip("background",1);
  144.       with(this.background)
  145.       {
  146.          moveTo(borderWidth,0);
  147.          beginFill(lightCol,100);
  148.          lineTo(w - borderWidth,0);
  149.          lineTo(w - borderWidth,h - borderWidth);
  150.          lineTo(borderWidth,h - borderWidth);
  151.          lineTo(borderWidth,borderWidth);
  152.          endFill();
  153.       }
  154.       this.createEmptyMovieClip("boxoutBorder",2);
  155.       with(this.boxoutBorder)
  156.       {
  157.          lineStyle(borderWidth,darkCol,40);
  158.          moveTo(0,0);
  159.          lineTo(w,0);
  160.          lineTo(w,h);
  161.          lineTo(0,h);
  162.          lineTo(0,0);
  163.          lineStyle(borderWidth,darkCol,100);
  164.          moveTo(1,1);
  165.          lineTo(w - 1,1);
  166.          lineTo(w - 1,h - 1);
  167.          lineTo(1,h - 1);
  168.          lineTo(1,1);
  169.       }
  170.    }
  171.    function setSize(w, h)
  172.    {
  173.       this.__bgHeight = h;
  174.       this.__bgWidth = w;
  175.       this.drawBackground(true,w,h);
  176.    }
  177.    function set image(imagePath)
  178.    {
  179.    }
  180.    function removeHTMLTags(htmlText)
  181.    {
  182.       var _loc6_ = function(txt, index)
  183.       {
  184.          return txt.indexOf("<",index);
  185.       };
  186.       var _loc8_ = function(txt, index)
  187.       {
  188.          return txt.indexOf(">",index);
  189.       };
  190.       var _loc2_ = new Array();
  191.       var _loc7_ = 0;
  192.       var _loc9_ = undefined;
  193.       var _loc10_ = undefined;
  194.       while(_loc7_ < htmlText.length)
  195.       {
  196.          _loc9_ = _loc6_(htmlText,_loc7_);
  197.          if(_loc9_ == -1)
  198.          {
  199.             break;
  200.          }
  201.          _loc10_ = _loc8_(htmlText,_loc9_);
  202.          var _loc3_ = _loc6_(htmlText,_loc10_);
  203.          while(_loc3_ == _loc10_ + 1)
  204.          {
  205.             _loc10_ = _loc8_(htmlText,_loc3_);
  206.             _loc3_ = _loc6_(htmlText,_loc10_);
  207.          }
  208.          _loc2_.push({start:_loc9_,end:_loc10_});
  209.          _loc7_ = _loc10_ + 1;
  210.       }
  211.       var _loc5_ = 0;
  212.       while(_loc5_ < _loc2_.length)
  213.       {
  214.          _loc9_ = _loc2_[_loc5_].start;
  215.          var _loc11_ = htmlText.charAt(_loc2_[_loc5_].start);
  216.          _loc10_ = _loc2_[_loc5_].end;
  217.          var _loc12_ = htmlText.charAt(_loc2_[_loc5_].end);
  218.          var _loc16_ = htmlText.substring(_loc9_ + 1,_loc10_);
  219.          _loc5_ = _loc5_ + 1;
  220.       }
  221.       if(_loc2_.length != 0)
  222.       {
  223.          var _loc18_ = "";
  224.          if(_loc2_[0].start > 0)
  225.          {
  226.             _loc18_ += htmlText.substring(0,_loc2_[0].start);
  227.          }
  228.          var _loc4_ = 0;
  229.          while(_loc4_ < _loc2_.length - 1)
  230.          {
  231.             var _loc13_ = _loc2_[_loc4_].end + 1;
  232.             var _loc15_ = _loc2_[_loc4_ + 1].start;
  233.             _loc18_ += htmlText.substring(_loc2_[_loc4_].end + 1,_loc2_[_loc4_ + 1].start);
  234.             _loc4_ = _loc4_ + 1;
  235.          }
  236.          if(_loc2_[_loc2_.length - 1].end < htmlText.length - 1)
  237.          {
  238.             _loc18_ += htmlText.substring(_loc2_[_loc2_.length - 1].end + 1);
  239.          }
  240.          return _loc18_;
  241.       }
  242.       return htmlText;
  243.    }
  244.    function sendMessage(p_msgtxt)
  245.    {
  246.       this.dispatchEvent({target:this,type:"press",msgtxt:p_msgtxt});
  247.    }
  248. }
  249.